package com.hh.test.reference;

public class WeakReference {

	class Car {
		Car(String name) {
			this.name = name;
		}

		private String name;

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

	}

	public static void main(String[] args) {
		java.lang.ref.WeakReference<Car> car = new java.lang.ref.WeakReference<WeakReference.Car>(
				new WeakReference().new Car("X4"));
		while (true) {
			if (car.get() == null) {
				System.out.println("has GC car is null");
			} else {
				System.out.println("car exists ");
			}

		}
	}
}
